/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MENU_EDIT.java
 *
 * Created on Oct 5, 2010, 9:17:02 PM
 */

package Java;

import java.awt.Component;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.JOptionPane;

/**
 *
 * @author akmal
 */
public class MENU_EDIT extends javax.swing.JFrame {

    private String url = "jdbc:oracle:thin:@localhost:1521:XE";
    private String pass_id = "HR";
    private String pass_pw = "hr";
    String newline = "\n";
    DefaultListModel List;
    DefaultListModel TempList;
    Connection con;
    ResultSet rset;
    Statement stat;
    boolean edit = false;
    boolean add = false;

    /** Creates new form MENU_EDIT */
    public MENU_EDIT() throws SQLException {
        super("MENU PROFILE");
        initComponents();
        this.setLocationRelativeTo(null);
        connect();
        populateData();
        FoodTypeCombo.setVisible(false);
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        FoodList = new javax.swing.JList();
        DoneButton = new javax.swing.JButton();
        addButton = new javax.swing.JButton();
        editButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        resetButton = new javax.swing.JButton();
        FoodTypeCombo = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        FoodCode = new javax.swing.JTextField();
        FoodType = new javax.swing.JTextField();
        FoodName = new javax.swing.JTextField();
        FoodPrice = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jSeparator1.setBounds(0, 50, 700, 10);
        jLayeredPane1.add(jSeparator1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator2.setBounds(0, 420, 700, 20);
        jLayeredPane1.add(jSeparator2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodList.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        FoodList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        FoodList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                FoodListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(FoodList);

        jScrollPane1.setBounds(20, 90, 210, 310);
        jLayeredPane1.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        DoneButton.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14));
        DoneButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        DoneButton.setText("DONE");
        DoneButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        DoneButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DoneButtonActionPerformed(evt);
            }
        });
        DoneButton.setBounds(560, 440, 100, 40);
        jLayeredPane1.add(DoneButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addButton.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        addButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        addButton.setText("ADD");
        addButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });
        addButton.setBounds(270, 340, 90, 40);
        jLayeredPane1.add(addButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        editButton.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        editButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        editButton.setText("EDIT");
        editButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButtonActionPerformed(evt);
            }
        });
        editButton.setBounds(370, 340, 90, 40);
        jLayeredPane1.add(editButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        deleteButton.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        deleteButton.setText("DELETE");
        deleteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        deleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteButtonActionPerformed(evt);
            }
        });
        deleteButton.setBounds(470, 340, 90, 40);
        jLayeredPane1.add(deleteButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        saveButton.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        saveButton.setText("SAVE");
        saveButton.setEnabled(false);
        saveButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });
        saveButton.setBounds(570, 340, 90, 40);
        jLayeredPane1.add(saveButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        resetButton.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        resetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        resetButton.setText("Reset");
        resetButton.setEnabled(false);
        resetButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });
        resetButton.setBounds(550, 100, 90, 40);
        jLayeredPane1.add(resetButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodTypeCombo.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        FoodTypeCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select", "Appetizer", "Main Dish", "Dessert", "Drink" }));
        FoodTypeCombo.setEnabled(false);
        FoodTypeCombo.setBounds(550, 150, 90, 26);
        jLayeredPane1.add(FoodTypeCombo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setFont(new java.awt.Font("DejaVu Serif Condensed", 1, 24));
        jLabel1.setText("MENU PROFILE");
        jLabel1.setBounds(40, 10, 310, 50);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        jLabel2.setText("Food Code :");
        jLabel2.setBounds(280, 110, 90, 20);
        jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        jLabel3.setText("Food Type :");
        jLabel3.setBounds(280, 150, 100, 16);
        jLayeredPane1.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14));
        jLabel4.setText("Food Name :");
        jLabel4.setBounds(280, 190, 100, 16);
        jLayeredPane1.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        jLabel5.setText("Food Price :");
        jLabel5.setBounds(280, 230, 110, 16);
        jLayeredPane1.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 13)); // NOI18N
        jLabel6.setText("RM");
        jLabel6.setBounds(370, 230, 21, 20);
        jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 14)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Available Food", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("DejaVu Serif Condensed", 3, 15))); // NOI18N
        jLabel7.setBounds(10, 70, 230, 340);
        jLayeredPane1.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel9.setBounds(260, 320, 410, 80);
        jLayeredPane1.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodCode.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 13)); // NOI18N
        FoodCode.setFocusable(false);
        FoodCode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FoodCodeActionPerformed(evt);
            }
        });
        FoodCode.setBounds(370, 110, 170, 25);
        jLayeredPane1.add(FoodCode, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodType.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 13)); // NOI18N
        FoodType.setFocusable(false);
        FoodType.setBounds(370, 150, 170, 25);
        jLayeredPane1.add(FoodType, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodName.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 13)); // NOI18N
        FoodName.setFocusable(false);
        FoodName.setBounds(370, 190, 170, 25);
        jLayeredPane1.add(FoodName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FoodPrice.setFont(new java.awt.Font("DejaVu Serif Condensed", 0, 13)); // NOI18N
        FoodPrice.setFocusable(false);
        FoodPrice.setBounds(400, 230, 70, 25);
        jLayeredPane1.add(FoodPrice, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Menu Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("DejaVu Serif Condensed", 3, 15))); // NOI18N
        jLabel8.setBounds(250, 70, 430, 340);
        jLayeredPane1.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract2.jpg"))); // NOI18N
        jLabel23.setText("jLabel23");
        jLabel23.setBounds(0, 0, 700, 500);
        jLayeredPane1.add(jLabel23, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void DoneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DoneButtonActionPerformed

        this.setVisible(false);
        new EMPLOYEE_MENU().setVisible(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_DoneButtonActionPerformed

    private void FoodCodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FoodCodeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_FoodCodeActionPerformed

    private void FoodListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_FoodListValueChanged

        String select  = (String) FoodList.getSelectedValue();
        String select2 = select.substring(0, 5);
        System.out.println("CODE SELECTED-> "+select2);
        String query;

        query = "SELECT * FROM FOOD WHERE FOOD_CODE = '"+select2+"'";

        try
        {
            rset = getResultSet(query);
            while(rset.next())
            {
                FoodCode.setText(rset.getString("FOOD_CODE"));
                FoodType.setText(rset.getString("FOOD_TYPE"));
                FoodName.setText(rset.getString("FOOD_NAME"));
                FoodPrice.setText(rset.getString("FOOD_PRICE"));
            }
            con.close();
        }
        catch (SQLException ex)
        {
            Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_FoodListValueChanged



    
    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed

        FoodName.setText("");
        FoodPrice.setText("");
        add=true;
        edit=false;

        //addded by shyan-----------------------------------------
        int life=0;
        String[] choices = { "Appetizer", "Main Dish", "Drink","Dessert" };
        String input = (String) JOptionPane.showInputDialog(null, null, "What?", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
	System.out.println("Choice-> "+input);

        // GENERATE THE NEXT FOOD CODE BASE ON DIFFERENT TYPE OF DISH
        String temp = "SELECT FOOD_CODE FROM FOOD WHERE FOOD_TYPE='"+input+"'AND FOOD_CODE >= ALL (SELECT FOOD_CODE FROM FOOD WHERE FOOD_TYPE='"+input+"')";
        System.out.println(temp);
        try
        {
            rset = getResultSet(temp);
            if (rset.next())
            {
                String value=rset.getString("FOOD_CODE");
                System.out.println(value);
                String subValue1=value.substring(0,1);
                String subValue2=value.substring(1,5);
                System.out.println("subValue1 = "+subValue1+"  subValue2 ="+subValue2);
                life = Integer.parseInt(subValue2);
                life = life+1;
                System.out.println("Life ->"+subValue1+life+"");
                
                FoodCode.setText(subValue1+life);
                
            }
        }
        catch (SQLException ex) {
            ex.printStackTrace();
        }
        //---------------------------------------------------


        
        FoodCode.setFocusable(false);
        FoodType.setText(input);
        FoodType.setFocusable(false);
        saveButton.setEnabled(true);
        addButton.setEnabled(false);
        editButton.setEnabled(false);
        deleteButton.setEnabled(false);
        resetButton.setEnabled(true);

        FoodTypeCombo.setVisible(false);
        FoodList.setEnabled(false);
        FoodList.setFocusable(false);

        FoodName.setFocusable(true);
        FoodPrice.setFocusable(true);

        // TODO add your handling code here:
    }//GEN-LAST:event_addButtonActionPerformed

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed

        clear();
        reset();
        // TODO add your handling code here:
    }//GEN-LAST:event_resetButtonActionPerformed

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed

        edit = true;
        add = false;
        saveButton.setEnabled(true);
        //FoodTypeCombo.setEnabled(true);
        //FoodTypeCombo.setVisible(true);
        resetButton.setEnabled(true);

        addButton.setEnabled(false);
        deleteButton.setEnabled(false);
        editButton.setEnabled(false);
        FoodType.setFocusable(false);

        FoodName.setFocusable(true);
        FoodPrice.setFocusable(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_editButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed

        String query = null;
        String code  = FoodCode.getText();
        String type  = FoodType.getText();
        String price = FoodPrice.getText();
        String name  = FoodName.getText();
        //String d = (String) FoodTypeCombo.getSelectedItem();
        //d = d.trim();

        if(add==true)
        {
            if ( price.equals("") || name.equals("") )
           {
             JOptionPane.showMessageDialog(null, "Fill/Select Something First!");
           }
           else
           { 
              String message = "Do you confirm to add?";
              String title = "Confirmation";
              query = "INSERT INTO FOOD VALUES('"+code+"','"+type+"','"+name+"','"+price+"')";
              System.out.println(query);
              int reply = JOptionPane.showConfirmDialog(null,message,title,JOptionPane.YES_NO_OPTION);
              if(reply == JOptionPane.YES_OPTION)
              {
                   
                   try
                   {
                        stat = con.createStatement();
                        stat.executeUpdate(query);
                        JOptionPane.showMessageDialog(null, "Menu added");
                        reset();
                        clear();
                        populateData();
                        stat.close();
                        //con.close();
                   }
                   catch (SQLException ex)
                   {
                        Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                   }
               }
            
            }
          }
          else //if(edit==true)
          {
                //String d = (String) FoodTypeCombo.getSelectedItem();
                //FoodType.setEnabled(true);
                FoodType.setFocusable(false);

                String d1= FoodType.getText().toString();
                System.out.println("d1 = "+d1);
                if(code.equals("") || price.equals("") || name.equals(""))
                {
                    JOptionPane.showMessageDialog(null, "Fill/Select Something First!");
                }
                else
                {
                    String message = "Do you confirm to update?";
                    String title = "Confirmation";
                    query = "UPDATE FOOD SET FOOD_NAME = '"+name+"', FOOD_PRICE = '"+price+"'"+
                            " WHERE FOOD_CODE = '"+code+"'";
                    System.out.println(query);
                    int reply = JOptionPane.showConfirmDialog(null,message,title,JOptionPane.YES_NO_OPTION);
                    if(reply == JOptionPane.YES_OPTION)
                    {
                        

                        try
                        {
                            connect();
                            stat = con.createStatement();
                            stat.executeUpdate(query);
                            JOptionPane.showMessageDialog(null, "Menu updated");

                            reset();
                            clear();
                            populateData();
                            con.close();
                        }
                        catch (SQLException ex)
                        {
                          Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
            }
        
        // TODO add your handling code here:
    }//GEN-LAST:event_saveButtonActionPerformed

    private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed

        String a = FoodCode.getText();
        String b = FoodPrice.getText();
        String c = FoodName.getText();
        String d = FoodType.getText();

        if(a.equals("") || b.equals("") || c.equals("") || d.equals(""))
        {
            JOptionPane.showMessageDialog(null, "No item to delete!");
        }
        else
        {
            String message = "Do you confirm to delete?";
            String title = "Confirmation";

            int reply = JOptionPane.showConfirmDialog(null,message,title,JOptionPane.YES_NO_OPTION);
            if(reply == JOptionPane.YES_OPTION)
            {
                String query = "DELETE FROM FOOD WHERE FOOD_CODE = '"+a+"' AND FOOD_NAME = '"+c+"' "+
                               "AND FOOD_PRICE = '"+b+"' AND FOOD_TYPE = '"+d+"'";
                try
                {
                    connect();
                    stat = con.createStatement();
                    stat.executeUpdate(query);

                    JOptionPane.showMessageDialog(null, "Menu deleted");

                    reset();
                    clear();
                    populateData();
                }
                catch (SQLException ex)
                {
                    JOptionPane.showMessageDialog(null,"FAILED !");

                    Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_deleteButtonActionPerformed


    private void populateData() throws SQLException
    {

        String query = "SELECT FOOD_CODE,FOOD_NAME FROM FOOD ORDER BY FOOD_CODE ASC";

        List = new DefaultListModel();
        rset = getResultSet(query);
        while(rset.next())
        {
           List.addElement(rset.getString("FOOD_CODE")+"       "+rset.getString("FOOD_NAME"));
        }
        FoodList.setModel(List);
     }

    private void reset()
    {
        edit = false;
        add = false;
        FoodList.setEnabled(true);
        FoodTypeCombo.setVisible(false);

        saveButton.setEnabled(false);
        FoodTypeCombo.setEnabled(false);
        resetButton.setEnabled(false);

        addButton.setEnabled(true);
        deleteButton.setEnabled(true);
        editButton.setEnabled(true);
        FoodType.setEnabled(true);

        FoodCode.setFocusable(false);
        FoodType.setFocusable(false);
        FoodName.setFocusable(false);
        FoodPrice.setFocusable(false);
    }

    private ResultSet getResultSet(String s) throws SQLException {
        connect();
        ResultSet rs = null;
        try {
            stat = con.createStatement();
            rs = stat.executeQuery(s);
        } catch (SQLException ex) {
            Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
        }

        return rs;
    }

    private void connect() throws SQLException
    {
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        System.out.println("Driver Loaded");
        con = DriverManager.getConnection(url,pass_id,pass_pw);
        System.out.println("Database Connected");
 

    }

    private void clear()
    {
        FoodCode.setText("");
        FoodName.setText("");
        FoodPrice.setText("");
        FoodType.setText("");
        FoodTypeCombo.setSelectedIndex(0);

    }
    
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new MENU_EDIT().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(MENU_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton DoneButton;
    private javax.swing.JTextField FoodCode;
    private javax.swing.JList FoodList;
    private javax.swing.JTextField FoodName;
    private javax.swing.JTextField FoodPrice;
    private javax.swing.JTextField FoodType;
    private javax.swing.JComboBox FoodTypeCombo;
    private javax.swing.JButton addButton;
    private javax.swing.JButton deleteButton;
    private javax.swing.JButton editButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton resetButton;
    private javax.swing.JButton saveButton;
    // End of variables declaration//GEN-END:variables

}
